
package com.pikts.acc2blender.data;

public class Fifo {
  private Element first;

  private Element last;

  public Fifo() {
		first=null;
		last=null;
  }

  public void push(DataStruct data) {
	//	Element el = first;
	//	first = new Element(data, el);
	//	if (el!= null) {
	//	el.putPrevious(first);
	//	}
		Element el = first;
		el = new Element(data, el);
		if (first!= null) {
			first.putPrevious(el);
		}
		else last=el;
		first=el;
		
  }

  public DataStruct pop() {
		if (last != null && last.getPrevious() != null ) {
			Element temp = last;
			last = last.getPrevious(); 
			last.putNext(null);
			return temp.getData();
		} 
		else
			return (DataStruct) null;
  }

  public boolean isFirstEmpty() {
		if (first==null) {
			return true;
		}
		else
			return false;
  }

  public boolean isLastEmpty() {
		//if (last==null && last==null || last.getPrevious()== null) {
		if (last != null && last.getPrevious() != null ) {
			return false;
		}
		else
			return true;
  }

}
